//  Sage Android Client.
//  Connect to a Sage server, remotely execute commands and display results.
//
//  Copyright (C) 2010, Harald Schilly <harald.schilly@gmail.com>
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.sagemath.android;

import org.sagemath.android.Calculation;
import org.sagemath.android.Server;
import org.sagemath.android.CalculationListener;
import org.sagemath.android.ConnectionListener;

interface CalculationAPI {
  
  void setServer(out Server server);
  
  /** 
   * kill the current connection (if there is one) 
   */
  void killConnection();
  
  int getStatus();
  
  void stopService();
  
  void addCalcListener(CalculationListener listener);
  
  void removeCalcListener(CalculationListener listener);
  
  void addConnListener(ConnectionListener listener);
  
  void removeConnListener(ConnectionListener listener);
  
  void setKeepAlive(boolean keepAlive);
  
  boolean getKeepAlive();
  
  /**
   * This is the way to start a new calculation. The Service creates a
   * Calculation object and returns its unique ID. Later, the Calculation
   * object is sent back.<br>
   * TODO Maybe we should move the creation of the object to the client?
   */ 
  int calculate(String code);
  
  /**
   * if true, a calculation is currently running.
   */
  boolean isCalculationRunning();
  
  /**
   * clears all unprocessed calculations from the working queue
   */
  void clearQueue();
  
  /**
   * returns the size of the queue
   */
  int getQueueSize();
	  
  /**
   * if set to true, a notification in the notification bar
   * is shown when calculation has finished (only useful if
   * app is paused or closed)
   */
   void setShowNotification(boolean b); 
}